<html>
<head><meta charset="utf-8"><title>What are static move closures? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html">What are static move closures?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226613635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226613635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226613635">(Feb 17 2021 at 04:49)</a>:</h4>
<p>There are a half dozen uses of <code>static move ||</code> in rustc, and in all cases it seems to be used on a generator expression, but rust-analyzer doesn't know about that keyword combination and neither do I. The <a href="https://doc.rust-lang.org/nightly/unstable-book/language-features/generators.html">unstable book</a> doesn't talk about this, and the <a href="https://github.com/rust-lang/rfcs/pull/2033">original generator RFC</a> doesn't even talk about generators and spends all its words on async/await instead.</p>



<a name="226650285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226650285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226650285">(Feb 17 2021 at 12:41)</a>:</h4>
<p>it marks the generator as immovable</p>



<a name="226650313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226650313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226650313">(Feb 17 2021 at 12:41)</a>:</h4>
<p>this allows holding references to locals across yield points</p>



<a name="226650375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226650375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226650375">(Feb 17 2021 at 12:42)</a>:</h4>
<p>and is what async constructs use internally</p>



<a name="226697591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226697591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226697591">(Feb 17 2021 at 17:55)</a>:</h4>
<p>Is this like pinning it on construction or something?</p>



<a name="226697794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226697794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226697794">(Feb 17 2021 at 17:57)</a>:</h4>
<p>it doesn't get pinned automatically</p>



<a name="226697801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226697801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226697801">(Feb 17 2021 at 17:57)</a>:</h4>
<p>Do the implemented traits change as a result? How is calling code affected?</p>



<a name="226697998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226697998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226697998">(Feb 17 2021 at 17:58)</a>:</h4>
<p>the generator no longer implements <code>Unpin</code> I think</p>



<a name="226698023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226698023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226698023">(Feb 17 2021 at 17:58)</a>:</h4>
<p>been a while since I looked at this though</p>



<a name="226698060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226698060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226698060">(Feb 17 2021 at 17:59)</a>:</h4>
<p>ah, interesting</p>



<a name="226698421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226698421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226698421">(Feb 17 2021 at 18:01)</a>:</h4>
<p>Are there any plans for an actual generator RFC? The original one was pretty explicit about not being a real RFC and only being used to get usage data, but async/await already stabilized a while ago so I guess the data is in</p>



<a name="226699005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226699005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226699005">(Feb 17 2021 at 18:05)</a>:</h4>
<p><a href="https://github.com/rust-lang/rfcs/pull/2781">https://github.com/rust-lang/rfcs/pull/2781</a></p>



<a name="226699049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20are%20static%20move%20closures%3F/near/226699049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20are.20static.20move.20closures.3F.html#226699049">(Feb 17 2021 at 18:05)</a>:</h4>
<p>is recently active and relevant, but not yet exposing it, AFAIK</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>